<template>
  <div class="toolbar" @click.stop>
    <el-tooltip content="最小化" placement="bottom">
      <el-icon class="item-tool" @click="Tools(0)"><Minus /></el-icon>
    </el-tooltip>
    <el-tooltip content="最大化" placement="bottom">
      <el-icon class="item-tool" @click="Tools(1)"><FullScreen /></el-icon>
    </el-tooltip>
    <el-tooltip content="关闭" placement="bottom">
      <el-icon class="item-tool" @click="Tools(2)"><CloseBold /></el-icon>
    </el-tooltip>
  </div>
</template>
<script lang="ts" setup>
import { Minus, CloseBold, FullScreen } from '@element-plus/icons-vue'

const Tools = async (index: number) => {

  switch (index) {
    case 0:
      window.electron.ipcRenderer.send('minimize-window')
      break;
    case 1:
      const isMax = await window.electron.ipcRenderer.invoke('maximize-window')
      if (isMax) {
        console.log('最大化');
      } else {
        console.log('取消最大化');
      }
      break;
    case 2:
      window.electron.ipcRenderer.send('close-window')
      break;
    default:
      break;
  }

}
</script>

<style scoped lang="scss">
.toolbar {
  display: flex;
  align-content: center;
  justify-content: flex-end;
}
.item-tool {
  margin-right: 20px;
}
</style>
